package main

import (
	"ai_bash/api"
	"fmt"

	"github.com/spf13/cobra"
)

var (
	chatMode   bool
	normalMode bool
	uploadMode bool
)

var rootCmd = &cobra.Command{
	Use:   "app",
	Short: "An ai shell",
	Run: func(cmd *cobra.Command, args []string) {
		if !chatMode && !normalMode && !uploadMode {
			normalMode = true
		}

		if chatMode {
			api.Chat()
		}
		if normalMode {
			if len(args) > 0 {
				api.Normal(args[0])
			} else {
				fmt.Println("请输入命令描述")
			}
		}
		if uploadMode {
			if len(args) > 0 {
				api.Upload(args[0])
			} else {
				fmt.Println("请输入命令描述")
			}
		}
	},
}

func init() {
	rootCmd.Flags().BoolVarP(&chatMode, "chat", "c", false, "chat mode")
	rootCmd.Flags().BoolVarP(&normalMode, "normal", "n", false, "normal mode")
	rootCmd.Flags().BoolVarP(&uploadMode, "upload", "u", false, "upload mode")
}

func main() {
	if err := rootCmd.Execute(); err != nil {
		fmt.Println(err)
	}
}
